version: '2'
services:
    nginx:
        build:
            context: ./
            dockerfile: docker/nginx.docker
        volumes:
            - ./:/var/www
            - ./docker/nginx/ssl:/etc/nginx/ssl
        ports:
            - "8080:443"
        links:
            - php-fpm
    php-fpm:
        build:
            context: ./
            dockerfile: docker/php-fpm.docker
        volumes:
            - ./:/var/www
        links:
            - mysql
            - redis
            - elasticsearch
        environment:
            - "DB_PORT=3306"
            - "DB_HOST=mysql"
            - "REDIS_PORT=6379"
            - "REDIS_HOST=redis"
            - "ELASTICSEARCH_HOSTS=elasticsearch:9200"
    php-cli:
        build:
            context: ./
            dockerfile: docker/php-cli.docker
        volumes:
            - ./:/var/www
        links:
            - mysql
            - redis
            - elasticsearch
        environment:
            - "DB_PORT=3306"
            - "DB_HOST=mysql"
            - "REDIS_PORT=6379"
            - "REDIS_HOST=redis"
            - "ELASTICSEARCH_HOSTS=elasticsearch:9200"
        tty: true
    mysql:
        image: mysql:5.7
        volumes:
            - ./storage/docker/mysql:/var/lib/mysql
        environment:
            - "MYSQL_ROOT_PASSWORD=secret"
            - "MYSQL_USER=app"
            - "MYSQL_PASSWORD=secret"
            - "MYSQL_DATABASE=app"
        ports:
            - "33061:3306"
    redis:
        image: redis:3.0
        ports:
            - "63791:6379"
    node:
        image: node:8.6-alpine
        volumes:
            - ./:/var/www
        working_dir: /var/www
        tty: true
    elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch:6.2.2
        environment:
            - bootstrap.memory_lock=true
            - "ES_JAVA_OPTS=-Xms128m -Xmx128m"
        ulimits:
            memlock:
                soft: -1
                hard: -1
        volumes:
            - ./storage/docker/elasticsearch:/usr/share/elasticsearch/data
        ports:
            - "9201:9200"